<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"   prefix="c" %>

<%@page import="grupobbva.pe.operhc.util.Constant"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String versionApp=(String)request.getSession().getAttribute(Constant.VERSIONAPP_SESSION);
%>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Imprimir Contrato</title>
	<link rel="stylesheet" type="text/css" media="print" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="print" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="print" href="<%=request.getContextPath()%>/css/operhc_style.css" />
	<link rel="stylesheet" type="text/css" media="print"  href="<%=request.getContextPath()%>/css/print.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/buttonOHC.css" />
	
	<script type="text/javascript" src='<%= request.getContextPath()%>/dwr/interface/ConsultaActualAction.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'></script>
	<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>	
	<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/encabezado.js?ver<%=versionApp%>" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/formatters.js?ver<%=versionApp%>" type="text/javascript"></script>
	
<script type="text/javascript" charset="UTF-8">

var FAMILIA_TARJETAS = '<%=Constant.FAMILIA_TARJETAS%>';
var FAMILIA_PRESTAMOS = '<%=Constant.FAMILIA_PRESTAMOS%>';

var myColNames  = ['', 'Tasa', 'SubProducto', 'Divisa', 'Importe a Contratar'];
var myDataModel = [
                   {name : 'valSeleccion',			index : 'valSeleccion',			width : VAL_WIDTH.XSMALL, 		formatter: valSeleccionFormat, 		unformat: genericUnFormat, 	align: 'center', 	sortable:false},
                   {name : 'valTasa',				index : 'valTasa' ,				width : VAL_WIDTH.VSMALL, 		formatter: 'currency',  formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, suffix:" %"},   align: 'right', sortable:false},
            	   {name : 'desSubProducto',		index : 'desSubProducto', 		width : VAL_WIDTH.BMED,		formatter: desSubProductoFormat, 	unformat: genericUnFormat,	align: 'left',		sortable:false},
            	   {name : 'divisa',				index : 'divisa', 				width : VAL_WIDTH.VSMALL,		formatter: divisaFormat, 			unformat: genericUnFormat, 	align: 'center',	sortable:false},
            	   {name : 'valLimiteContrato',		index : 'valLimiteContrato', 	width : VAL_WIDTH.SMALL,		formatter: 'currency',  formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2},   align: 'right', 	sortable:false}];
            	   
function loadInitialProducts(){
	var indicatorInitial = window.opener.document.getElementById('indicatorInitial').value;
	document.getElementById('indicatorInitial').value = indicatorInitial;
	var miTabla = document.getElementById("tablePrintBody");
	miTabla.innerHTML = "";
	
	ConsultaActualAction.consultarProductosAjax(indicatorInitial, function(data){
		
		var arrayGeneral  = data.listGeneral;			
		miTabla.innerHTML = data.cadenaHTML;
			
		if(arrayGeneral.length > 0){
			codProductDefault = '';
			for(var z=0;z<arrayGeneral.length;z++){
				
				var arraySubProductos = arrayGeneral[z];
				mostrarTablaSubProd(arraySubProductos, arraySubProductos[0].idTable, myColNames, myDataModel);
				
				if(codProductDefault != '' && codProductDefault != arraySubProductos[0].codProducto){
					document.getElementById("li-"+codProductDefault).innerHTML += "<br>"; 
				}
				
				codProductDefault = arraySubProductos[0].codProducto;
				
				if(z == arrayGeneral.length-1){
					document.getElementById("li-"+codProductDefault).innerHTML += "<br>";
				}
			}
		}
		printpage();
	});	
}



function printpage(){
	window.print();
	window.close();
}

function mostrarTablaSubProd(data, idTableForm, colNames, dataModel){
	
	jQuery("#"+idTableForm).jqGrid(
	{
		beforeSelectRow: function(){},
		data 	 	: data,
		datatype 	: "local",
		height   	: "100%",
		weight 	 	: 1000,
		colNames 	: colNames,
		colModel 	: dataModel,
		viewrecords : true,
		loadonce	: true,
		multiselect : false,			
		subGrid    	: false,
		footerrow  	: false,
		loadComplete :
           function (data) {}
	});
}

</script>
<style type="text/css">

      .ui-jqgrid tr.jqgrow td {white-space: nowrap;}

</style>
</head>
<body onload="loadInitialProducts();">
<input type='hidden' name="indicatorInitial" id="indicatorInitial" value="" />
<div id="divButtonPrint">
<br/>
<%--
<input type="button" value="Imprimir" onclick="printpage()" />
&nbsp;<a href="#" onclick="printpage();" class="buttonOHC">IMPRIMIR</a>
 --%>
</div>
<br/>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td id="tablePrintBody" valign="top" align="center"></td></tr>
</table>

</body>

<script type="text/javascript" charset="UTF-8">

//document.getElementById("tblPrintOffers").outerHTML = window.opener.document.getElementById("tableMainBody").innerHTML;

</script>

</html>